var mySlider = {};

Rhy.onDocumentReady(function(){
    
    Rhy.extra.tooltip.apply($rh('#tab1'), "Sample about drag & drop");
    Rhy.extra.tooltip.apply($rh('#tab2'), "Sample about sliders");
    Rhy.extra.tooltip.apply($rh('#tab3'), "Sample about resizers");
    Rhy.extra.tooltip.apply($rh('#tab4'), "Sample about autocomplete");
    
    Rhy.extra.autocomplete.apply($rh('#ac'), {
        source: 'js/acdata.js',
        type: 'json'
    });
    
    Rhy.extra.autocomplete.apply($rh('#ac2'), {
        source: ['PHP', 'Java', 'C++', 'Python', 'Javascript'],
        onSelect: function(field){
            console.log(field.rhyAcData);
        }
    });
    
    Rhy.extra.slider.apply(
        $rh('#slider'), 
        { 
            mode: "h", 
            value: 200,
            min: 175,
            max: 255,
            reverse: false,
            onSlide: function(o){ 
                console.log(o.rhySlideValue);
            } 
        }
    );

    Rhy.extra.slider.apply(
        $rh('#r-slider'), 
        { 
            mode: "h", 
            value: 200,
            min: 175,
            max: 255,
            reverse: true,
            onSlide: function(o){ 
                console.log(o.rhySlideValue);
            } 
        }
    );

    Rhy.extra.slider.apply(
        $rh('#v-slider'), 
        { 
            mode: "v", 
            value: 100,
            min: 50,
            max: 200,
            reverse: false,
            onSlide: function(o){
                console.log(o.rhySlideValue);
            }
        }
    );

    Rhy.extra.slider.apply(
        $rh('#rv-slider'), 
        { 
            mode: "v", 
            value: 100,
            min: 50,
            max: 200,
            reverse: true,
            onSlide: function(o){
                console.log(o.rhySlideValue);
            }
        }
    );

    Rhy.extra.resize.apply($rh('#resize'), {});

    Rhy.extra.tab.apply('sample-tab', {
        onChange: function(){
            Rhy.extra.slider.refresh($rh('#slider'));
            Rhy.extra.slider.refresh($rh('#v-slider'));
            Rhy.extra.slider.refresh($rh('#r-slider'));
            Rhy.extra.slider.refresh($rh('#rv-slider'));
            Rhy.extra.resize.refresh($rh('#resize'));
        }
    });

    Rhy.extra.drag.apply($rh('#target'), {onDrop: function(o, h){
        if(h == null){
            Rhy.extra.anim({
                object: o,
                property: 'left',
                from: Rhy.extra.drag.endLocation.x,
                to:   Rhy.extra.drag.startLocation.x,
                duration: 500
            }).start();

            Rhy.extra.anim({
                object: o,
                property: 'top',
                from: Rhy.extra.drag.endLocation.y,
                to:   Rhy.extra.drag.startLocation.y,
                duration: 500
            }).start();
        }
    }});

    Rhy.extra.drag.apply($rh('#target2'));
    Rhy.extra.drop.apply($rh('#holder')); 
});  